#pragma once
//#include "Inputs.h"
#include "UltimateOpenALPrecompiled.h"
#include "UltimateSoundSubsystem.h"
#include <AL/alut.h>

#define ALUT_SAFE_CALL(call, message) {call; \
	ALenum error = alutGetError(); \
	if(error != ALUT_ERROR_NO_ERROR) \
	Ogre::String msg = message; \
	}
	//if(error != ALUT_ERROR_NO_ERROR) \
	//Ogre::LogManager::getSingleton().logMessage(message + Ogre::String(" ") + Ogre::String(alutGetErrorString(error))); \

#define AL_SAFE_CALL(call, message) {call; \
	ALenum error = alGetError(); \
	if(error != AL_NO_ERROR) \
	Ogre::String msg = message; \
	}
	//if(error != AL_NO_ERROR) \
	//Ogre::LogManager::getSingleton().logMessage(message + Ogre::String(" ") + Ogre::String(alutGetErrorString(error))); \

class _UltimateOpenALExport GameAudio: public UltimateSoundSubsystem
{
	std::map<std::string, ALuint> sourceMap;
	int currentSourceMapIndex;
	
	ALuint loadFile(const char* filename);

	void createSource(ALuint* source);

public:

	GameAudio();
	GameAudio(int argc, char** argv);

	void helloAudioWorld();

	Ogre::Vector3 getAudioListenerPosition();
	Ogre::Vector3 getAudioListenerDirection();
	
	void setAudioListenerPose(Ogre::Vector3 pos, Ogre::Vector3 dir);

	void createAudioWithName(
		Ogre::String name, Ogre::String filePath, bool looping,
		float pitch, Ogre::Vector3 position);

	void setAudioWithName(
		Ogre::String name, Ogre::String filePath, bool looping,
		float pitch, Ogre::Vector3 position);

	void playAudioByName(Ogre::String name);

	void playAudioFromFile(Ogre::String filePath, bool looping,
		float pitch, Ogre::Vector3 position);

	void stopAudioByName(Ogre::String name);

	void stopAllAudioSource();

	void deleteAllAudioSource();
    
    ~GameAudio(); 
};
